package com.bjut.vehicleshow.controller;

import com.bjut.vehicleshow.pojo.CarTrainingDO;
import com.bjut.vehicleshow.service.CarTrainingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("carTraining/")
@Api(value = "carTraining", tags = "carTraining")
public class CarTrainingController {

    @Autowired
    private CarTrainingService carTrainingService;

    @GetMapping(value = "carNames")
    @ApiOperation(httpMethod = "GET", value = "carNames")
    public List<String> getCarNames() {
        return carTrainingService.getAllCarName();
    }

    @GetMapping(value = "car/{carName}")
    @ApiOperation(httpMethod = "GET", value = "car")
    public List<CarTrainingDO> getCars(@PathVariable("carName") String carName) {
        return carTrainingService.getByName(carName);
    }
}
